'use strict';

import React from 'react'
import { render } from 'react-dom'
import { Provider ,connect} from 'react-redux'
import App from './containers/App'
import Main from './containers/Main'
import Too from './containers/Too'
//import DevTools from './containers/DevTools'
import { createStore,compose ,applyMiddleware ,combineReducers,} from 'redux'
import thunk from 'redux-thunk';
import devTools from 'remote-redux-devtools';
import { Router, Route,  hashHistory} from 'react-router';//browserHistory
import { syncHistoryWithStore} from 'react-router-redux'
import todoApp from './reducers'
import './css/index.less'

import injectTapEventPlugin from 'react-tap-event-plugin';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import MyAwesomeReactComponent from './components/MyAwesomeReactComponent';
import FastClick from 'fastclick';
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
    //alert(navigator.userAgent);
    FastClick.attach(document.body);
} else if (/(Android)/i.test(navigator.userAgent)) {

} else {

};
FastClick.attach(document.body);
injectTapEventPlugin();
const enhancer = compose(
    applyMiddleware(thunk),
    devTools({realtime:true})
);
let store = createStore(todoApp,enhancer);
devTools.updateStore(store);
const history = syncHistoryWithStore(hashHistory, store);
let xmlhttp;
xmlhttp=new XMLHttpRequest();
xmlhttp.onreadystatechange=function()
{
    if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
        console.log(xmlhttp.responseText)
    }
};
xmlhttp.open("GET","/api",true);
xmlhttp.send();
let rootElement = document.getElementById('root');
render(
    <Provider store={store}>


    <Router history={ history}>
        <Route path="/" component={Main}/>
        <Route path="/about" component={Too}/>
        <Route path="/app" component={App}/>

    </Router>
    </Provider>,
    rootElement
);
//connect()(Router);